package com.curso.sesion10;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Employee implements Serializable {

	private static final long serialVersionUID = -5579597967025759040L;

	public String name;
	public String address;
	public transient int SSN;
	public int number;
	private static final String SECRET_KEY = "bfglbnpo6fhdm1321321(&%/(#)(";

	public void mailCheck() {
		System.out.println("Mailing a check to " + name
				+ " " + address);
	}
	
	private void writeObject(ObjectOutputStream oos) {
		try {
			oos.defaultWriteObject();
			oos.writeChars(name+SECRET_KEY);
			oos.writeChars(address+SECRET_KEY);
			oos.writeInt(SSN*2);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	private void readObject(ObjectInputStream ois) {
		try {
			ois.defaultReadObject();
			name = ois.readLine();
			address = ois.readLine();
			SSN = ois.readInt();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
	}
}